<template>
  <div>
    <van-sticky @scroll="handleScroll" offset-top="-30">
      <!-- NavBar区域 -->
      <van-nav-bar v-if="flag" z-index="1" />
      <van-nav-bar v-else title="黑马优购" z-index="1">
        <template #left>
          <div class="left_arrow" @click="()=>{ $router.go(-1) }">
            <van-icon name="arrow-left" />
            <span>返回</span>
          </div>
        </template>
      </van-nav-bar>
    </van-sticky>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  data() {
    return {
      flag: false
    };
  },
  methods: {
    handleScroll(e) {
      if (e.scrollTop < 46) return (this.flag = false);
      this.flag = true;
    }
  }
};
</script>

<style lang="scss" scoped>
</style>